package com.ax.associator.store.controller;

import com.ax.associator.store.common.ajax.AjaxRes;
import com.ax.associator.store.common.log.LogInfo;
import com.ax.associator.store.common.log.OperateType;
import com.ax.associator.store.common.utils.PageUtils;
import com.ax.associator.store.common.utils.base.Const;
import com.ax.associator.store.domain.Attachment;
import com.ax.associator.store.domain.BaseAssociator;
import com.ax.associator.store.domain.BusiAttachRelation;
import com.ax.associator.store.domain.memberDto;
import com.ax.associator.store.service.storeAssociatorService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/web/storeAssociator/")
public class storeAssociatorController {

    @Autowired
    private storeAssociatorService store;


    @RequestMapping("insertMember")

    public AjaxRes insertMember(AjaxRes ajaxRes,@RequestBody BaseAssociator baseAssociator){
        try{
            Integer integer=store.insertSelective(baseAssociator);
            ajaxRes.setSucceed(integer, Const.SAVE_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }

    @RequestMapping("queryAssociator")

    public AjaxRes queryAssociatorMapper(AjaxRes ajaxRes,@RequestBody Map<String,Object> map){
        try{
           List<BaseAssociator> list= store.queryAssociatorMapper(map);
           ajaxRes.setSucceed(list,Const.DATA_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }

    @RequestMapping("queryMember")

    public PageUtils queryMember(@RequestBody Map<String, Object> params){

        PageUtils list=store.queryMember(params);

        return list;
    }

    @RequestMapping("updateBaseAssociator")

    public AjaxRes updateBaseAssociator(AjaxRes ajaxRes,@RequestBody BaseAssociator baseAssociator){
        try{
            Integer integer=store.updateBaseAssociator(baseAssociator);
            ajaxRes.setSucceed(integer,Const.UPDATE_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }

    @RequestMapping("deleteAssociator")

    public AjaxRes deleteAssociator(AjaxRes ajaxRes,@RequestBody Long associatorId){
        try{
            Integer integer=store.deleteAssociator(associatorId);
            ajaxRes.setSucceed(integer,Const.DEL_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }
}
